package jp.sourceforge.akjrcp.ui.param;


import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

public abstract class AbstractParamCompositeItem extends Composite implements ParamItem{
protected ParamItemActionListener paramActionListener;
protected ParamItem self;

public static final int LAYOUT_FILL_BOTH=-1;
public static final int LAYOUT_FILL_HORIZONTAL=0;
	public AbstractParamCompositeItem(Composite parent, int style) {
	super(parent,style);
	self=this;
}

	public void setParamItemActionListener(ParamItemActionListener listener) {
		this.paramActionListener=listener;
	}


	protected class ModifiCheck implements ModifyListener{

		public void modifyText(ModifyEvent e) {
			if(paramActionListener!=null){
				paramActionListener.paramItemModified(self);
			}
		}
		
	}

	protected class SelectionCheck implements SelectionListener{

		public void widgetDefaultSelected(SelectionEvent e) {
			if(paramActionListener!=null){
				paramActionListener.paramItemModified(self);
			}
		}

		public void widgetSelected(SelectionEvent e) {
			if(paramActionListener!=null){
				paramActionListener.paramItemModified(self);
			}
		}
		
	}
	
	protected class WheelCheck implements Listener{

		public void handleEvent(Event event) {
			 switch ( event.type ) {
			  case SWT.MouseWheel:
				  if(paramActionListener!=null){
						paramActionListener.paramItemModified(self);
					}
				  break;  
			 	}
			}
		
	}
}
